<? if ($c = stack('name')) {

	$s = component_settings($c);

	ob_start(); ?><script type="text/javascript">
	
	Date.prototype.toSimpleDate = function() {
		var t, m = ((t = this.getMonth() + 1) < 10) ? ("0" + t) : "" + t, d = ((t = this.getDate()) < 10) ? ("0" + t) : "" + t;
		return d + "." + m + "." + this.getFullYear();
	}
	
	jQuery(function($) {
						 
		$.ajax({dataType:'xml', type:'get', url:"http://www.ufs.kiev.ua/xml/cash_fx.php",
			success:function(data){
				var w = $(data.responseText), h = [], currency, b, s,
				currencies = "<?=$s['currencies']?>".split(','),
				date = (new Date(w.find("date").text())).toSimpleDate();

				h.push("<h3><?=$s['title']?></h3>");
				h.push("<table>");
				h.push('<thead><tr><td>' + date + '</td><td><?=$s['buy']?></td><td><?=$s['sell']?></td></tr></thead>');
				h.push("<tbody>");

				for (var i in currencies) if (currencies.hasOwnProperty(i)) {
					currency = w.find("currency[name=" + currencies[i] + "] bank[mfo=<?=$s['bank_mfo']?>]");
					b = currency.find("bid").text();
					s = currency.find("ask").text();
					h.push("<tr><td>" + currencies[i] + "</td><td>" + b + "</td><td>" + s + "</td></tr>");
				}

				h.push("</tbody></table>");
				
				$("#cpn_<?=$c?>_rates").html(h.join(''));
			}
			
		});
		
	});
	
	</script><? $SCRIPT[] = ob_get_clean();


	?><div id="cpn_<?=$c?>_rates" class="rates"></div><?

	unstack();
} ?>